package com.guoyh.mvvmwanandroid.weight.viewpager

import android.content.Context
import com.guoyh.bilui.utils.UIUtils.getColorm
import com.guoyh.baseutils.mylog.Loger
import com.ruffian.library.widget.helper.RTextViewHelper
import com.ruffian.library.widget.iface.RHelper
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView

class CustmSelTitleView(context: Context) :
    SimplePagerTitleView(context), RHelper<RTextViewHelper> {
    private val mHelper: RTextViewHelper = RTextViewHelper(context, this, null)
    override fun getHelper(): RTextViewHelper {
        return mHelper
    }

    var minScale = 0.8f

    override fun onEnter(index: Int, totalCount: Int, enterPercent: Float, leftToRight: Boolean) {
        super.onEnter(index, totalCount, enterPercent, leftToRight)    // 实现颜色渐变
        Loger.dd("onEnter")
//        val color = ArgbEvaluatorHolder.eval(enterPercent, mHelper.textColorNormal, mHelper.textColorSelected)
        //选中
        val color = getColorm("#0000ff")

//        mHelper.setTextColorNormal(color)
//        scaleX = minScale + (1.0f - minScale) * enterPercent
//        scaleY = minScale + (1.0f - minScale) * enterPercent

    }

    override fun onLeave(index: Int, totalCount: Int, leavePercent: Float, leftToRight: Boolean) {
        super.onLeave(index, totalCount, leavePercent, leftToRight)    // 实现颜色渐变
        //未选中
        Loger.dd("onLeave")
//        val color = ArgbEvaluatorHolder.eval(leavePercent,  mHelper.textColorSelected, mHelper.textColorNormal)
//        val color = getColor("#ff0000")
//        mHelper.setTextColorNormal(color)
//        scaleX = 1.0f + (minScale - 1.0f) * leavePercent
//        scaleY = 1.0f + (minScale - 1.0f) * leavePercent
    }


    override fun onSelected(index: Int, totalCount: Int) {
        mHelper.setTextColorNormal(getColorm("#0000ff"))
    }
    override fun onDeselected(index: Int, totalCount: Int) {
        mHelper.setTextColorNormal(getColorm("#ff0000"))


    }

}